package cn.vivi.mail.controller;

import cn.vivi.common.entity.vo.MailVo;
import cn.vivi.common.util.Result;
import cn.vivi.mail.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("mails")
public class MailController {

    @Autowired
    private MailService mailService;

    @PostMapping
    public Result<Boolean> sendMail(@RequestBody MailVo mailVo) {
        return mailService.sendHtmlMail(mailVo.getTo(), mailVo.getSubject(), mailVo.getContent()) ? Result.success(): Result.error("发送邮件失败");
    }


}
